package com.sky.controller.admin;

import com.sky.properties.AliOssProperties;
import com.sky.result.Result;
import com.sky.utils.AliOssUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Api(tags = "公共接口")
@RequestMapping("/admin/common")
public class CommonController {

	//文件上传工具类
	@Autowired
	AliOssUtil aliOssUtil;

	/**
	 * 文件上传
	 * @param file
	 * @return
	 * @throws IOException
	 */
	@ApiOperation("文件上传")
	@PostMapping("/upload")
	public Result upload(@RequestParam("file") MultipartFile file) throws IOException {
		Result result = aliOssUtil.upload(file);
		return result;
	}

}
